package top.fengleifeng.question;

import top.fengleifeng.util.Constants;

/**
 * @author : fengelfeing
 * @version V1.0
 * @Project: leetcode-test
 * @Package : top.fengleifeng.question
 * @Description:
 * @Date: 2020年11月11日4:32 下午
 */
public class Zn个骰子的点数 {

    class Solution {

        public double[] dicesProbability(int n) {
            double[] before = new double[]{1 / 6d, 1 / 6d, 1 / 6d, 1 / 6d, 1 / 6d, 1 / 6d};
            if (n == 1) {
                return before;
            }
            for (int i = 2; i <= n; i++) {
                double[] now = new double[5 * i + 1];
                for (int j = 0; j < before.length; j++) {
                    for (int k = 0; k < 6; k++) {
                        now[j + k] += before[j] / 6;
                    }
                }
                before = now;
            }
            return before;
        }

    }

    public static void main(String[] args) {
        double[] doubles = new Zn个骰子的点数().new Solution().dicesProbability(3);
        Constants.printArr(doubles);
    }
}
